Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for all Diffie-Hellman Key Exchange protocols. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thb-sb
Copy link

@thb-sb thb-sb commented Mar 19, 2024

Add support for all Diffie-Hellman Key Exchange protocols.

In the SSH 2.0 protocol, there are roughly three different Diffie-Hellman key exchange protocols:

  • The first one, simply called Diffie-Hellman Key Exchange, defined in RFC4253 § 8
  • The second one that use ECDH, defined in RFC6239 § 4
  • The last one, called Diffie-Hellman Group and Key Exchange, defined in RFC4419 § 3

The Diffie-Hellman key exhange protocol depends on the KEX algorithms that has been negociated
during the Key Exchange Init stage.

This commit adds support for these three Diffie-Hellman key exchange protocols, by implementing
a new API called SshKEX.

To use SshKEX, users must have retrieved the SshPacketKeyExchange
from the client and the server. Then, SshKEX::init is called to initialize
the KEX stage.

Later, depending on the type of the messages that come, SshKEX::parse_ssh_packet
is called to feed the pending KEX stage.

Finally, the various sub-stages specific to each DH key exchange protocols are
exposed through the SshKEX interface.

Tests have been added to ensure that these three protocols are well supported.

If the feature flag integers is enabled, some sub-stages may expose BigInt
instead of the integers in raw format.

No copy or no memory allocation is used here.

@thb-sb thb-sb marked this pull request as ready for review March 19, 2024 11:20
@thb-sb thb-sb marked this pull request as draft March 19, 2024 13:16
@thb-sb thb-sb force-pushed the pr5 branch 8 times, most recently from 7519a33 to 73948f4 Compare March 21, 2024 16:14
@thb-sb thb-sb changed the title Add support for Diffie-Hellman Request, RequestOld and Group. Add support for all Diffie-Hellman Key Exchange protocols. Mar 21, 2024
@thb-sb thb-sb marked this pull request as ready for review March 21, 2024 16:24
@thb-sb thb-sb force-pushed the pr5 branch 3 times, most recently from 3c91f0a to 9d79f6b Compare March 22, 2024 14:29
In the SSH 2.0 protocol, there are roughly three different Diffie-Hellman key exchange protocols:

 - The first one, simply called Diffie-Hellman Key Exchange, defined in [RFC4253 § 8](https://datatracker.ietf.org/doc/html/rfc4253#section-8)
 - The second one that use ECDH, defined in [RFC6239 § 4](https://datatracker.ietf.org/doc/html/rfc6239#section-4)
 - The last one, called Diffie-Hellman Group and Key Exchange, defined in [RFC4419 § 3](https://datatracker.ietf.org/doc/html/rfc4419#section-3)

The Diffie-Hellman key exhange protocol depends on the KEX algorithms that has been negociated
during the _Key Exchange Init_ stage.

This commit adds support for these three Diffie-Hellman key exchange protocols, by implementing
a new API called `SshKEX`.

To use `SshKEX`, users must have retrieved the `SshPacketKeyExchange`
from the client and the server. Then, `SshKEX::init` is called to initialize
the KEX stage.

Later, depending on the type of the messages that come, `SshKEX::parse_ssh_packet`
is called to feed the pending KEX stage.

Finally, the various sub-stages specific to each DH key exchange protocols are
exposed through the `SshKEX` interface.

Tests have been added to ensure that these three protocols are well supported.

If the feature flag `integers` is enabled, some sub-stages may expose `BigInt`
instead of the integers in raw format.

No copy or no memory allocation is used here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants